package test01;

import java.util.Random;

public class p01 {
    public static class MyThread extends Thread{
        public void run(){
            Random random=new Random();
            while (true){
                //打印线程名称
                System.out.println(Thread.currentThread().getName());
                try{
                    //随机暂停0~9秒
                   Thread.sleep(random.nextInt(10));
                }
                catch (Exception e){
                    e.printStackTrace();
                }
            }
        }
    }
    public static void main(String[] args) {
        MyThread myThread1=new MyThread();
        myThread1.start();
        Random random=new Random();
        while(true){
            System.out.println(Thread.currentThread().getName());
            try{
                //随机暂停0~9秒
                //随机暂停0~9秒
                Thread.sleep(random.nextInt(10));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
